<%@page import="com.hamizhong.iflowers.utils.MyColumnIndicator"%>
<%@page import="com.hamizhong.iflowers.web.vo.OrdersVO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<%@include file="../../common/common_admin.jsp" %>
<title>订单详情</title>
</head>

<%
	OrdersVO ordersVO = (OrdersVO)request.getAttribute("ordersVO");
%>

<body>
	<div class="displayPageHeader">当前位置：订单管理 >> 订单管理>> 订单详情</div>
	<div class="pageDiv">
		<div class="pageHeadDiv"><font>订单详情</font></div>
		<div class="infoDiv">
			<div id="itemListDiv" class="itemListDiv">
				<table border="1px" width="100%">
					<tr>
						<td>商品图片</td>
						<td><div style="width: 60px;height: 60px;"><img width="56px" height="56px"  style="margin: 2px;" alt="" src="<%=request.getContextPath() %>/<%=ordersVO.getGoodsVO().getGoodsPictureS() %>" /></div></td>
					</tr>
					<tr>
						<td>订单编号</td>
						<td><%=ordersVO.getOrderNum() %></td>
					</tr>
					<tr>
						<td>商品名称</td>
						<td><%=ordersVO.getGoodsVO().getGoodsName() %></td>
					</tr>
					<tr>
						<td>购买数量</td>
						<td><%=ordersVO.getGoodsCnt() %></td>
					</tr>
					<tr>
						<td>订单总价</td>
						<td><%=ordersVO.getOrderPrice() %></td>
					</tr>
					<tr>
						<td>订单状态</td>
						<td><%=ordersVO.getOrderStateStr() %></td>
					</tr>
					<tr>
						<td>最新时间</td>
						<td><%=ordersVO.getDoneDateStr() %></td>
					</tr>
					<tr>
						<td>创建时间</td>
						<td><%=ordersVO.getCreateDateStr() %></td>
					</tr>
					<tr>
						<td>收货城市</td>
						<td><%=ordersVO.getCityVO().getCityName() %></td>
					</tr>
					<tr>
						<td>收货人姓名</td>
						<td><%=ordersVO.getConsigneeName() %></td>
					</tr>
					<tr>
						<td>收货人电话</td>
						<td><%=ordersVO.getConsigneePhone() %></td>
					</tr>
					<tr>
						<td>收货地邮编</td>
						<td><%=ordersVO.getZip() %></td>
					</tr>
					<tr>
						<td>收货人地址</td>
						<td><%=ordersVO.getConsigneeAddr() %></td>
					</tr>
					<tr>
						<td>订单备注</td>
						<td><%=ordersVO.getRemarks() %></td>
					</tr>
				</table>
			</div>
		</div>
	</div>
	<div class="pageDiv">
		<div class="pageHeadDiv"><font>操作栏</font></div>
		<div class="infoDiv">
			<input style="margin: 10px 0;" type="button" onclick="closeWindow();" value="关闭窗口">
		<%
			if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_A) {
		%>
			<input style="margin: 10px 0;" type="button" onclick="updateOrderState('<%=ordersVO.getOrderId() %>','<%=MyColumnIndicator.O_ST_BACK_B %>')" value="退回订单">
			<input style="margin: 10px 0;" type="button" onclick="updateOrderState('<%=ordersVO.getOrderId() %>','<%=MyColumnIndicator.O_ST_B %>')" value="确认发货">
		<%
			}else if(ordersVO.getOrderState() == MyColumnIndicator.O_ST_BACK_A) {
		%>
			<input style="margin: 10px 0;" type="button" onclick="updateOrderState('<%=ordersVO.getOrderId() %>','<%=MyColumnIndicator.O_ST_BACK_C %>')" value="确认用户退订">
		<%
			}
		%>
		</div>
	</div>
	<div class="margin_50"></div>
</body>

<script type="text/javascript">
	//父窗口对象
	var parentWindow = window.dialogArguments;
	
	function closeWindow() {
		window.close();
	}
	
	function updateOrderState(orderId, newState) {
		//alert(orderId+"|"+origState+"|"+newState);
		$.ajax({
			url: '<%=request.getContextPath() %>/admin/ajaxUpdateOrderState.action',
			data: {
				"orderId": orderId,
				"newState": newState
			},
			type: 'post',
			async: false,
			dataType: 'json',
			success: function(res) {
				var rs = res.result;
				if(rs != 0) {
					alert(res.msg);
					closeWindow();
				}else {
					alert("操作成功！");
					closeWindow();
					parentWindow.initOrderList(1);
				}
			}
		});
	}
	
</script>

</html>